package org.sky.algorithm.tree;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class BinaryTree {

    private static final Logger log = LoggerFactory.getLogger(BinaryTree.class);

    /**
     * 二叉树节点
     */
    private BinaryTreeNode root;

    public BinaryTreeNode getRoot() {
        return root;
    }

    public void setRoot(BinaryTreeNode root) {
        this.root = root;
    }

    /**
     * 前序遍历
     */
    public void frontShow() {

        log.info("前序遍历");

        root.frontShow();

        log.info("结束");
    }

    /**
     * 中序遍历
     */
    public void middleShow() {
        log.info("中序遍历");
        root.middleShow();
        log.info("中序遍历");
    }

    /**
     * 后序遍历
     */
    public void afterShow() {
        log.info("后序遍历");
        root.afterShow();
        log.info("后序遍历");
    }

    public BinaryTreeNode frontSearch(int i) {
        return root.frontSearch(i);
    }

}
